package demo

import scala.collection.mutable.ListBuffer

object ListDemo {

  //定长List
  var a1 = List("hello scala", "hello java", "hello c++")

  var a2 = ListBuffer(1, 2, 3)
  val f = a2.append(4)

  //list 转为Array
  val array = a2.toArray

  val x=  a1.map(line => line.split(" "))

  //扁平化，将每个单词都变成一个元素
   a1.flatMap(item => item.split(" "))


  val a3 = a1.groupBy(word => word)

  def main(args: Array[String]): Unit = {
    a3.foreach(x => println(x))
  }

}
